</table><!--table --><br />

 <?php
  $time = microtime();
  $time = explode(' ', $time);
  $time = $time[1] + $time[0];
  $finish = $time;
  $total_time = round(($finish - $start), 4);
  //AUTO SETUP timediff
  if ($server_time == '') {
      $time = strtotime($time_difference . " hours");
      $mytime = date("Y-m-d H:i:s", $time);
      
      $timezone = new DateTimeZone("Europe/Berlin");
      $date = new DateTime();
      $date->setTimezone($timezone);
      
      $time2 = $db->query("SELECT NOW()");
      $datetime = $db->fetch_array($time2,'assoc');
      
      $servertime = $datetime['NOW()'];
      $s_timediff = ceil((strtotime($date->format($date_format)) - strtotime($servertime)) / 60);
      
      if (strtotime($mytime) != strtotime($servertime)) {
          echo "<span style='color:green'>Warning: <br/><b>Local time:</b> " . date("Y-m-d H:i:s", $time);
          echo " <br> <b>Server time</b>: " . $datetime['NOW()'];
          echo "<br >Time difference: " . ceil((strtotime($date->format($date_format)) - strtotime($servertime)) / 60) . " minutes";
          echo "<br ><b>Autosetup complete!</b> Please refresh this page!</span";
      }
      write_value_of('$server_time', "", $s_timediff);
  }

  if ($users_online == 1) {
      $session = session_id();
      $time = time();
      //SET TIME 10 Minute
      $time_check = $time - $users_online_minutes * 60;
      
      $sql = "SELECT * FROM " . $table_prefix . "online_users ORDER BY user ASC";
      $result = $db->query($sql);
      $count = mysql_num_rows($result);
	  
	  if (isset($_SESSION['signed_in']))
	  {
	  $username = $_SESSION['user_name'];
	  $userip = $_SERVER['REMOTE_ADDR'];
	  $userid = isset($_SERVER['user_id']);
	  }
	  if (!isset($_SESSION['signed_in']))
	  {
	  $username = "guest";
	  $userip = $_SERVER['REMOTE_ADDR'];
	  $userid = -5;
	  }
	  $useragent = $_SERVER['HTTP_USER_AGENT'];
if ( strstr($_SERVER['HTTP_USER_AGENT'], "Googlebot" ) == true OR strstr($_SERVER['HTTP_USER_AGENT'], "googlebot" ) == true){
$username = "Google[bot]";
$userip = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$userid = -5;

$gbot = $db->query("DELETE FROM " . $table_prefix . "online_users WHERE user = '$username'");

}

/*
if ($_SESSION['signed_in'] == false)
{
$myFile = "file.txt";
$fh = fopen($myFile, 'a');
$stringData = $date->format($date_format)." - ".$username." | ".$_SERVER['REMOTE_ADDR']."\n $useragent\n";
fwrite($fh, $stringData);
fclose($fh);
}
*/
      if ($result["session"] == $session or $count == 0) {
          $sql1 = $db->query("INSERT INTO " . $table_prefix . "online_users(session, time, user_ip, user, user_id) VALUES('$session', '$time','$userip','$username',$userid )");
         $count == 1;
		 

      } else {
          $username = "guest";
		  $id = -5;
          if (isset($_SESSION['user_name'])) {
              $username = $_SESSION['user_name'];
              $id = $_SESSION['user_id'];
          }
          $result2 = $db->query("UPDATE " . $table_prefix . "online_users SET time='$time', user = '$username', user_id = $id , user_ip = '$_SERVER[REMOTE_ADDR]' WHERE session = '$session' ");
		  
      }
      $count_user_online = mysql_num_rows($result);
      $res = $db->query("SELECT session FROM " . $table_prefix . "online_users WHERE session='$session'");
	  
      if (mysql_num_rows($res) <= 0) {
	  if (!isset($_SESSION['user_name'])) {$_SESSION['user_name'] = "";}
	  if (!isset($_SESSION['user_id'])) {$_SESSION['user_id'] = "";}
	      $username = $_SESSION['user_name'];
          $id = $_SESSION['user_id'];
          if (!isset($_SESSION['signed_in'])) {
              $un = "";
              $id = -5;
          }
          if ( strstr($_SERVER['HTTP_USER_AGENT'], "Googlebot" ) == true){
$username = "Google[bot]";
$userip = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$userid = -5;
} 
          $sql1 = $db->query("INSERT INTO " . $table_prefix . "online_users(session, time, user_ip,user,user_id)VALUES('$session', '$time','" . $_SERVER["REMOTE_ADDR"] . "','$username',$id)");
		  
      }
      if ($hide_footer != -1) {
          echo "<table><tr><th><b>$l_whois_online</b> </th></tr><tr><td height='28'><b>$l_registered:</b> ";
          $members = mysql_num_rows($result);
          $c = 0;
          while ($row = $db->fetch_array($result,'assoc')) {
              $c++;
              $sufix = ",";
              if ($members <= $c) {
                  $sufix = "";
              }
			 if ($row['user'] == "guest") {$row['user'] = "";}
			 
              $user_online = "<a class='underline' href='user.php?u=$row[user_id]'>$row[user]</a>$sufix ";
              if ($row['user_id'] <= 0) {
                  $user_online = $row['user'] . " ";
                  $members -= 1;
              }
			  if ($row['user'] == "Google[bot]") {$members += 1;$user_online = "Google [bot]$sufix ";}

              echo $user_online;
          }
          if ($count_user_online == 0) {
              $count_user_online = 1;
          }
          if ($count_user_online == 0) {
              $count_user_online = 1;
          }
          $total_guests = $count_user_online - $members;
          $last = $db->query("SELECT user_name,user_id FROM " . $table_prefix . "users ORDER BY user_date DESC LIMIT 1");
		  
          $last_user = $db->fetch_array($last,'assoc');
          echo "</td></tr><tr><td height='28'>$l_tot_users $count_user_online $l_users_online $members $l_users_reg $l_and $total_guests $l_guests ($l_based_on $users_online_minutes $l_minutes)<br/>
$l_newest_member <a href='user.php?u=$last_user[user_id]'><b>$last_user[user_name]</b></td></tr></table>";
          
          // if over 10 minute, delete session
          $sql4 = "DELETE FROM " . $table_prefix . "online_users WHERE time<$time_check";
          $result4 = $db->query($sql4);
          
          $db->close();
      }
  }
?>
<table><tr><td height="28"><div align="center">Powered by <a class="underline" href="http://brevisbb.iz.rs" ><b>brevisBB</b></a> 0.9.8 | Created by <a class="underline" href="http://dota.iz.rs" ><b>Ivan A.</b></a> &copy; <?php
  print(date("Y"));
?>
 |  <a class="underline" href="credits.php" target="_blank"> <b> Credits </b></a></td></tr></table>
 
 <?php
  if ($_SESSION['user_level'] == 1 and $_SESSION['signed_in']) {
      echo "<div align='center'><a href = './adm'>Administration Control Panel</a></div>";
  }
  
  if ($page_gen == 1 or $show_queries == 1) {
      echo '<div align="center"><span style="font-size: 7pt">' . $l_page_gen . '';
  }
  if ($page_gen == 1) {
      echo ' ' . $total_time . ' ' . $l_seconds . '';
  }
  
  if ($show_queries == 1) {
      echo ' ' . $l_with_to . ' ' . $qqq . ' ' . $l_queries . '</span></div>';
  }
?>